
export default (font) => {
    let fontElement = window.$("<span></span>");
    fontElement.css("font", font);
    let fontWeight = '';
    let fontSize = '';
    let fontStyle = '';
    let fontFamily = fontElement.css("font-family").replace(/\"/g, "");

    // fontFamilyOptions.forEach(ff => {
    //     if (font.indexOf(ff) > -1) {
    //         if (ff.length > fontFamily.length) {
    //             fontFamily = ff;
    //         }
    //     }
    // });
    const ss = font.replace(fontFamily, '').trim();
    const array = ss.split(' ');
    array.forEach(v => {
        if (v === 'bold') {
            fontWeight = v;
        } else if (v === 'italic') {
            fontStyle = 'italic';
        } else if (v === 'normal') {
            fontWeight = 'normal';
        } else if (v.endsWith('px')) {
            fontSize = v.split("/")[0].replace('px', '');
        } else if (v.endsWith('pt')) {
            fontSize = v.replace('pt', '');
        } else if (!isNaN(parseInt(v, 10))) {
            if (parseInt(v, 10) > 500) {
                fontWeight = 'bold';
            }
        }
    });
    const rt = {
        fontFamily,
        fontSize,
        fontStyle,
        fontWeight
    };
    return rt;
}